package com.yc.autouser.controller;

import com.yc.autouser.entity.vo.RegisterUserVo;
import com.yc.autouser.service.SysUserService;
import com.yc.common.res.ResultClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Classname RegisterController
 * @Description 注册
 * @Version 1.0.0
 * @Date 2022/7/12 8:40
 * @Created by Mikechen
 */
@Controller
public class RegisterController {
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private SysUserService sysUserService;


    @PostMapping("/register")
    @ResponseBody
    public ResultClass register(@RequestBody RegisterUserVo registerUserVo){
        //密码加密
        String password=passwordEncoder.encode(registerUserVo.getPassword());
        registerUserVo.setPassword(password);
        return sysUserService.registerUser(registerUserVo);

    }

}
